home *** CD-ROM | disk | FTP | other *** search
- Path: news.informatik.uni-stuttgart.de!news
- From: Gerhard Muth <muth>
- Newsgroups: comp.lang.c++
- Subject: using const for structs?
- Date: 18 Jan 1996 18:23:08 GMT
- Organization: IPVR, University of Stuttgart, Germany
- Message-ID: <4dm36c$c1h@zdi.informatik.uni-stuttgart.de>
- NNTP-Posting-Host: bronto.informatik.uni-stuttgart.de
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.1N (X11; I; HP-UX A.09.05 9000/725)
- X-URL: news:comp.lang.c++
-
- // * Compiler-Problems with const!!
- //
- // The example is copied and modified from:
- // Practical C++ Programming,
- // Steve Oualline,
- // O'Reilly & Associates Inc.
- // ISBN 1-56592-139
- // Chapter 10, The C++ Preprocessor
- // #define versus const
- // (Page 156)
- //
- // If i try to compile it on a HP 700 with
- // $ CC const_struct.C
- // i get the following error message:
- // CC: "const_struct.C", line 35: error: cannot make a box (1284)
- //
- // I think, that i have to write a 2-parameter constructor,
- // but the book does not tell anything about that. It just says:
- //
- // "The #define directive is limited to defining simple
- // constants. The const statement can define almost any
- // type of C++ constant including things such as
- // structure classes."
- //
- // Question: Is the book wrong or is the compiler just bad?
- //
- // Gerhard.Muth@rus.uni-stuttgart.de
- //
-
- struct box {
- float width, heigth; // float was int before
- };
-
- const box blue_box();
- const box pink_box(1.0, 4.5); // this is line 35
-
- void main(void) {}
-
-